import { useState, useEffect } from 'react'
import { dropByCacheKey } from 'umi';


function Counter() {
  const [count, setCount] = useState(0)
  
  return (
    <div>
      <p>count: {count}</p>
      <button onClick={() => setCount(count => count + 1)}>add</button>
    </div>
  )
}

export default function Abc() {
  const [show, setShow] = useState(true)
  useEffect(()=> {
    console.log('two')
  }, [])
  const removeAlive = () => {
    dropByCacheKey('/second');
  }
  return (
    <div>
      <h1>Page two</h1>
      {show && (
          <Counter />
      )}
      <button onClick={() => setShow(show => !show)}>toggle</button>
      <button onClick={() => {removeAlive()}}>解除second页面缓存</button>
    </div>
  )
}
